package mock

import (
	"context"

	// "mall/common/resultx"
	"mall/service/forum/api/internal/svc"
	"mall/service/forum/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SearchLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchLogic {
	return &SearchLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SearchLogic) Search(req *types.MockSearchReq, headers *[]*types.Header) (resp *types.MockSearchResp, err error) {
	// return nil, resultx.NewErrCode(resultx.TOKEN_EXPIRE_ERROR)

	resp = &types.MockSearchResp{
		BaseListInfo: types.BaseListInfo{
			Current: 1,
		},
	}

	var respHeaders []*types.Header
	// respHeaders = append(respHeaders, &types.Header{
	// 	Key:   "x-class",
	// 	Value: "com.djx.DatabaseException",
	// })
	respHeaders = append(respHeaders, &types.Header{
		Key: "x-navigation-method",
	})
	respHeaders = append(respHeaders, &types.Header{
		Key: "x-env-type",
	})
	// respHeaders = append(respHeaders, &types.Header{
	// 	Key:   "authorization",
	// 	Value: "lcxIfTCC6IAA2yMM",
	// })
	*headers = respHeaders

	resp.List = append(resp.List, &types.MockSearchInfo{
		Content: "I feel I have come to know this hero, this wanderer.",
	})

	return
}
